#include "namedialog.h"

NameDialog::NameDialog(QWidget *parent) : QDialog(parent)
{
    setWindowTitle("为宠物起名");
    setMinimumSize(300, 150);

    QVBoxLayout *layout = new QVBoxLayout(this);
    QLabel *nameLabel = new QLabel("请给宠物起个可爱的名字吧:", this);
    layout->addWidget(nameLabel);
    nameLine = new QLineEdit(this);
    nameLine->setPlaceholderText("输入名字");
    layout->addWidget(nameLine);

    QPushButton *confirmButton = new QPushButton("确认", this);
    layout->addWidget(confirmButton);
    connect(confirmButton, &QPushButton::clicked, this, &NameDialog::confirmButtonClick);
}

void NameDialog::confirmButtonClick()
{
    if (!nameLine->text().isEmpty())
    {
        accept();
    }
}
